<!--{include(pe_tpl('header.html'));}-->
<div class="content">
	<div class="liucheng">我的购物车</div>
	<div class="mat10">
		<form method="post" id="form">
		<div class="gouwuche">
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="gwc_tb">
			<tr>
				<th width="60" style="padding-left:30px">商品图片</th>
				<th>商品名称</th>
				<th width="160">单价(元)</th>
				<th width="110">购买数量</th>
				<th width="100">操作</th>
			</tr>
			<!--{foreach($info_list as $k=>$v):}-->
			<tr id="{$k}" class="product_id">
				<td class="hotimg" style="padding-left:20px;padding-right:0"><img src="{pe_thumb($v['product_logo'], 40, 40)}" /></td>
				<td style="text-align:left;padding-left:0">
					<a href="{pe_url('product-'.$v['product_id'])}" title="{$v['product_name']}" target="_blank" class="cblue font14">{$v['product_name']}</a>
					<!--{if($v['prorule_name']):}-->
					<p class="c666"><!--{foreach(unserialize($v['prorule_name']) as $vv):}-->[{$vv['name']}：{$vv['value']}]&nbsp;&nbsp;<!--{endforeach;}--></p>
					<!--{endif;}-->
				</td>
				<td class="strong num font14">{$v['product_money']}</td>
				<td class="shuliang" style="padding-left:10px;">
					<span class="img1" onclick="pe_numchange('product_num[{$k}]', '-', 1);cart_num('{$k}', 'product_num[{$k}]')">-</span>
					<div class="shuliang_box"><input type="text" name="product_num[{$k}]" value="{$v['product_num']}" readonly /></div>
					<span class="img2" onclick="pe_numchange('product_num[{$k}]', '+', {$v['product_maxnum']});cart_num('{$k}', 'product_num[{$k}]')">+</span>
				</td>
				<td><a href="javascript:;" onclick="cart_del(this, '{$k}')">删除</a></td>
			</tr>
			<!--{endforeach;}-->
			</table>
		</div>
		<div class="fukuan">
			<div class="fl" style="padding:5px 10px">可获得积分：<span class="cgreen num" id="order_point_get">{$money['order_point_get']}</span> 点</div>
			<div class="fk_tb">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td>商品金额：</td>
				<td width="80" class="num font14 cred">¥ <span id="order_product_money">{$money['order_product_money']}</span></td>
			</tr>
			<tr>
				<td>运费：</td>
				<td class="num font14 cred">¥ <span id="order_wl_money">{$money['order_wl_money']}</span></td>
			</tr>
			<tr>
				<td>优惠券：
					<select name="order_quan_id">
					<option value="0" quan_money="0.0">不使用优惠券</option>
					<!--{foreach($quan_list as $v):}-->
					<option value="{$v['quanlog_id']}" quan_money="{$v['quan_money']}">【{$v['quan_money']}元】{$v['quan_name']}</option>
					<!--{endforeach;}-->
					</select>
				</td>
				<td class="num font14">- ¥ <span id="order_quan_money">0.0</span></td>
			</tr>
			<tr>
				<td>
					<span class="fr">您账户有 {$info['user_point']} 积分，可抵现 {$user_point_money} 元</span>
					<input type="checkbox" id="point_btn" class="fr mat2 mar5">
					<div class="clear"></div>
					<div id="point_html" style="display:none">使用 <input type="text" name="order_point_use" class="jf_input"> 积分</div>
				</td>
				<td class="num font14">- ¥ <span id="order_point_money">0.0</span></td>
			</tr>
			<tr>
				<td>应付金额：</td>
				<td class="num font18 cred strong">¥ <span id="order_money">{$money['order_money']}</span></td>
			</tr>
			</table>
			</div>
			<div class="clear"></div>			
		</div>
		<div style="border:1px #ddd solid; padding:10px 20px; margin-top:10px;">
			<h3 class="shxx_tt">付款方式</h3>
			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="shxx mat10">
			<!--{foreach($cache_payway as $k=>$v):}-->
			<!--{if(!$v['payway_state'])continue}-->
			<!--{$ii++;}-->
			<tr>
				<td width="60" align="right"><input type="radio" name="order_payway" id="{$k}" value="{$k}" <!--{if($ii==1):}-->checked="checked"<!--{endif;}--> /></td>
				<td width="190"><label for="{$k}">&nbsp;{$v['payway_name']}</label></td>
				<td class="c666"><label for="{$k}">{$v['payway_text']}</label></td>
			</tr>
			<!--{endforeach;}-->
			</table>
			<h3 class="shxx_tt mat10">收货信息</h3>
			<div class="shxx mat10">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="120" style="text-align:right;"><span class="cred1">*</span> 配送区域：</td>
					<td style="text-align:left;">
						<select name="province" id="province" class="inputselect"></select>
						<select name="city" id="city" class="inputselect"></select>
						<span id="province_show"></span> <span id="city_show"></span>
					</td>
				</tr>
				<tr>
					<td style="text-align:right;"><span class="cred1">*</span> 收货地址： </td>
					<td style="text-align:left;"><input type="text" name="user_address" value="{$info['user_address']}" class="inputall input400"> <span id="user_address_show"></span></td>
				</tr>
				<tr>
					<td style="text-align:right;"><span class="cred1">*</span> 收货姓名： </td>
					<td style="text-align:left;"><input type="text" name="user_tname" value="{$info['user_tname']}" class="inputall input150"> <span id="user_tname_show"></span></td>
				</tr>
				<tr>
					<td style="text-align:right;"><span class="cred1">*</span> 联系电话： </td>
					<td style="text-align:left;"><input type="text" name="user_phone" value="{$info['user_phone']}" class="inputall input150"> <span id="user_phone_show"></span></td>
				</tr>
				<tr>
					<td style="text-align:right;">用户留言： </td>
					<td style="text-align:left;"><textarea class="inputtext" name="order_text" style="width:400px;height:80px"></textarea></td>
				</tr>
				<tr>
					<td style="text-align:right;"></td>
					<td style="text-align:left;"><input type="hidden" name="pesubmit" />
				<input type="button" class="btn_05" value="提交订单" style="margin:0"></td>
				</tr>
				</table>
			</div>
		</div>
		</form>
	</div>
</div>
<script type="text/javascript" src="{$pe['host_root']}include/js/formcheck.js"></script>
<script type="text/javascript" src="{$pe['host_root']}include/js/shengshi.js"></script>
<script type="text/javascript">
$(function(){
	$("input[name='order_payway']").click(function(){
		$(this).parents("table").find("tr").removeClass('sel');
		$(this).parents("tr").addClass('sel');
	})
	$("input[name='order_payway']").each(function(){
		if ($(this).is(":checked")) $(this).parents("tr").addClass('sel');
	})
	//积分勾选
	$("#point_btn").click(function(){
		if ($(this).is(":checked")) {
			$("#point_html").show();
		}
		else {
			$("#point_html").hide();
			$("#order_point_money").html('0.0');		
		}
		order_money();
	})
	//积分输入
	$(":input[name='order_point_use']").keyup(function(){
		var point = $(this).val(), point_money = 0;
		if (point > {$info['user_point']}) {
			point = {$info['user_point']};
		}
		else if (point < 0 || isNaN(point)) {
			point = 0;
		}
		$(this).val(point);
		if ({round($cache_setting['point_money'])} > 0) {
			point_money = point/{$cache_setting['point_money']};
		}
		$("#order_point_money").html(point_money.toFixed(1));
		order_money();
	})
	//使用优惠券
	$(":input[name='order_quan_id']").live("change", function(){	
		$("#order_quan_money").html($(this).find("option:selected").attr("quan_money"));
		order_money();
	})	
})
function cart_num(product_id,name) {
	$.getJSON("{$pe['host_root']}index.php", {"mod":"order","act":"cartnum","product_id":product_id,"product_num":$(":input[name='"+name+"']").val()}, function(json){
		if (json.result) {
			$("#order_product_money").html(json.money.order_product_money);
			$("#order_wl_money").html(json.money.order_wl_money);
			$("#order_point_get").html(json.money.order_point_get);
			$(":input[name='order_quan_id']").html(json.quan_html);
			$("#cart_num").html(json.cart_num);
			//$("#order_money").html(json.money.order_money);
			order_money();
		}
	})
}
function cart_del(_this, product_id) {
	if (confirm('您确认要删除该商品吗?') == false) {
		return;
	}
	$.getJSON("{$pe['host_root']}index.php", {"mod":"order","act":"cartnum","product_id":product_id,"product_num":0}, function(json){
		if (json.result) {
			$(_this).parents("tr").remove();
			$("#order_product_money").html(json.money.order_product_money);
			$("#order_wl_money").html(json.money.order_wl_money);
			$("#order_point_get").html(json.money.order_point_get);
			$(":input[name='order_quan_id']").html(json.quan_html);
			$("#cart_num").html(json.cart_num);
			//$("#order_money").html(json.money.order_money);
			order_money();
		}
	})
}
function order_money() {
	var product_money = parseFloat($("#order_product_money").html());
	var wl_money = parseFloat($("#order_wl_money").html());
	var quan_money = parseFloat($("#order_quan_money").html());
	var point_money = parseFloat($("#order_point_money").html());
	var order_money = product_money + wl_money - quan_money - point_money;
	order_money = order_money >= 0 ? order_money : 0;
	$("#order_money").html(order_money.toFixed(1));
}
function order_add() {
	if ({count($info_list)}) {
		window.location.href="index.php?mod=order&act=add";
	}
	else {
		alert('您的购物车里还没有商品哦！');
	}
}
shengshi_init({"pval":"河南省","cval":"郑州市"});
var form_info = [
	{"name":"province", "mod":"str", "act":"change", "arg":"", "show_id":"province_show","show_error":"省份必须选择"},
	{"name":"city", "mod":"str", "act":"change", "arg":"", "show_id":"city_show","show_error":"城市必须选择"},
	{"name":"user_address", "mod":"str", "act":"blur", "arg":"", "show_id":"user_address_show","show_error":"地址必须填写"},
	{"name":"user_tname", "mod":"str", "act":"blur", "arg":"", "show_id":"user_tname_show","show_error":"姓名必须填写"},
	{"name":"user_phone", "mod":"match", "act":"blur", "arg":"phone", "show_id":"user_phone_show","show_error":"电话格式错误"}
]
$(":button").pe_submit(form_info, 'form');
</script>
<!--{include(pe_tpl('footer.html'));}-->